//
//  WmcTeamCell.swift
//  YPWatermarkCamera
//
//  Created by yupao_ios_macmini06 on 2022/9/15.
//

import UIKit

/// 个人相册cell
class WmcMyClouddAblumCell: WmcBaseTableCell {
    override func makeUI() {
        backgroundColor = .white

        contentView.addSubview(avatarView)
        contentView.addSubview(mainTitleLabel)
        contentView.addSubview(synTagLabel)
        contentView.addSubview(subTitleLabel)
        contentView.addSubview(arrowImageView)
        contentView.addSubview(lineView)
        contentView.addSubview(redDotView)

        avatarView.snp.makeConstraints { make in
            make.top.equalTo(20)
            make.left.equalTo(16)
            make.bottom.equalTo(-16)
            make.width.height.equalTo(38)
        }

        mainTitleLabel.snp.makeConstraints { make in
            make.top.equalTo(avatarView.snp.top).offset(-4)
            make.left.equalTo(avatarView.snp.right).offset(12)
        }

        synTagLabel.snp.makeConstraints { make in
            make.centerY.equalTo(mainTitleLabel.snp.centerY)
            make.left.equalTo(mainTitleLabel.snp.right).offset(16)
        }

        subTitleLabel.snp.makeConstraints { make in
            make.bottom.equalTo(avatarView.snp.bottom).offset(4)
            make.left.equalTo(avatarView.snp.right).offset(12)
        }

        arrowImageView.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.right.equalTo(-16)
            make.width.height.equalTo(18)
        }
        arrowImageView.contentMode = .scaleAspectFit
        arrowImageView.image = "teamAlbumRightArrow".wmc_image

        lineView.snp.makeConstraints { make in
            make.left.equalTo(16)
            make.right.equalTo(-16)
            make.bottom.equalToSuperview()
            make.height.equalTo(1)
        }
        lineView.backgroundColor = UIColor.wmc_grayH19_F5F5F5

        redDotView.snp.makeConstraints { make in
            make.left.equalTo(avatarView.snp.right).offset(-5)
            make.bottom.equalTo(avatarView.snp.top).offset(5)
            make.width.height.equalTo(8)
        }
    }

    func configure(model: WmcMediaTeamAlbumModel) {
        mainTitleLabel.text = model.name
        subTitleLabel.text = "全部照片\(model.totalResourceNum)张|今天已拍照\(model.currentDateResourceNum)张"
        synTagLabel.status = model.isSync ? .opend : .closed

        let member = WmcTeamMember(name: nil, img: "my_cloud_ablum_icon")
        avatarView.member = member
        redDotView.isHidden = !model.isShowRedDot
    }

    lazy var avatarView: WmcMemberAvatarView = {
        let view = WmcMemberAvatarView()
        return view
    }()

    lazy var mainTitleLabel: UILabel = {
        let view = UILabel()
        view.textColor = UIColor.wmc_grayH2_323233
        view.font = 17.yp.uiFont
        return view
    }()

    lazy var subTitleLabel: UILabel = {
        let view = UILabel()
        view.textColor = UIColor.wmc_grayH8_8A8A99
        view.font = 14.yp.uiFont
        return view
    }()

    /// 小红点
    lazy var redDotView: UIView = {
        let view = UIView()
        view.backgroundColor = UIColor.wmc_red_F54A45
        view.layer.cornerRadius = 4
        view.clipsToBounds = true
        view.isHidden = true
        return view
    }()

    lazy var synTagLabel: WmcSynTagLabel = {
        let view = WmcSynTagLabel(top: 3, left: 6, bottom: -3, right: -6)
        view.layer.cornerRadius = 2
        view.clipsToBounds = true
        return view
    }()
}
